<?php
$user = 'phpunion@gmail.com';
$pass = 'huangtuo';

$url[] = 'http://zc-project-crm.googlecode.com/svn/trunk/';
//$url[] = '/php/trunk/139api';
//$dir[] = "/data/rainuser/";
//$dir[] = "/data/139api/";
$dir[] = "/data/slash/crm.houdefanyi.com";
function update(){
        global $user,$pass,$dir;
        echo '<h2>svn update ...</h2>';
        foreach($dir as $v){
                $hl=popen("svn up --no-auth-cache --username {$user} --password {$pass} {$v} ","r");
                $read=stream_get_contents($hl);
                //$comm = "svn up --username {$user} --password {$pass} ";
                //$read = system($comm);
                echo "<pre>";
                printf($read);
                echo "</pre>";
                pclose($hl);
        }
}

function co(){
        global $user,$pass,$url,$dir;
        echo '<h2>svn checkout ...</h2>';
        foreach($url as $k=>$v){
                echo $command="svn co {$v} --username {$user} --password {$pass} ".$dir[$k];
                //exec($command);
                echo 'checkout Success!<br>';
        }
}

if($_GET['act']=='co'){
         co();
}else{
        update();
}
?>